package cn.iocoder.an.module.mold.dal.mysql.stockiorecords;

import java.util.*;

import cn.iocoder.an.framework.common.pojo.PageResult;
import cn.iocoder.an.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.an.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.an.module.mold.dal.dataobject.stockiorecords.StockIoRecordsDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.an.module.mold.controller.admin.stockiorecords.vo.*;

/**
 * 模具出入库记录 Mapper
 *
 * @author ykk
 */
@Mapper
public interface StockIoRecordsMapper extends BaseMapperX<StockIoRecordsDO> {

    default PageResult<StockIoRecordsDO> selectPage(StockIoRecordsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<StockIoRecordsDO>()
                .eqIfPresent(StockIoRecordsDO::getInOrOut, reqVO.getInOrOut())
                .likeIfPresent(StockIoRecordsDO::getCode, reqVO.getCode())
                .eqIfPresent(StockIoRecordsDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(StockIoRecordsDO::getWarehouseId, reqVO.getWarehouseId())
                .eqIfPresent(StockIoRecordsDO::getStorageId, reqVO.getStorageId())
                .eqIfPresent(StockIoRecordsDO::getAccountId, reqVO.getAccountId())
                .eqIfPresent(StockIoRecordsDO::getDrawingNoId, reqVO.getDrawingNoId())
                .eqIfPresent(StockIoRecordsDO::getOperatorId, reqVO.getOperatorId())
                .betweenIfPresent(StockIoRecordsDO::getOperateTime, reqVO.getOperateTime())
                .eqIfPresent(StockIoRecordsDO::getDescription, reqVO.getDescription())
                .betweenIfPresent(StockIoRecordsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(StockIoRecordsDO::getId));
    }

    // 在 StockIoRecordsMapper.java 中修改 getLastCode 方法签名
    String getLastCode(Integer inOrOut);

}